<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
  </head>
  <body>
    <div>div1</div>
    <div>div2</div>
    <div>div3</div>
    <script>
      //文档就绪事件:
      $(document).ready(function () {
        //编写jQuery
      });

      $(function () {
        //1、标签选择器:
        //获取所有的div元素(集合)
        var divList = $('div');
        // divList.each((index, item) => {
        //   console.log(item);
        // });
        console.log(divList); //jQuery的对象
        console.log(divList.length);
        for (var i = 0; i < divList.length; i++) {
          console.log(divList[i]); //js的对象
          //将js对象转换为jQuery的对象
          $(divList[i]).css('color', 'red');
        }
      });
    </script>
  </body>
</html>
